package com.ai.sml.action;

import com.ai.common.xml.util.ControlConstants.RETURN_CODE;
import com.ai.frame.bean.InputObject;
import com.ai.frame.bean.OutputObject;
import com.ai.frame.logger.Logger;
import com.ai.frame.logger.LoggerFactory;

public class FlowDictionaryAction extends BaseAction {
	private static final long serialVersionUID = -3901528412203856396L;
	private static final Logger logger = LoggerFactory.getActionLog(FlowDictionaryAction.class);

	// 根据应用范围获取相应的数据集合
	public void queryDictionaryListByRange() {
		InputObject inputObject = getInputObject();
		OutputObject outputObject = null;
		String cacheKey = "FLOW-DIC-" + inputObject.getParams().get("appliedRange");
		try {
			logger.info("queryDictionaryListByRange", cacheKey);
			outputObject = getCacheService().getFromCache(cacheKey);
			if (outputObject == null || RETURN_CODE.SYSTEM_ERROR.equals(outputObject.getReturnCode())) {
				outputObject = super.getOutputObject(inputObject);
				getCacheService().put2Cache(cacheKey, outputObject, 60 * 60);
			}
		} catch (Exception e) {
			logger.error("queryDictionaryListByRange", "queryDictionaryListByRange异常", e);
			outputObject = new OutputObject(RETURN_CODE.SYSTEM_ERROR, e.getMessage());
		}

		super.sendJson(super.convertOutputObject2Json(outputObject));
	}
}
